﻿#include "CRobCtrOper.h"
#include <QEventLoop>
#include <QTimer>
CRobCtrOper::CRobCtrOper(CDevDataBase *pDevDataRob)
{
	m_pDevDataRob = pDevDataRob;          //获取数组对象引用
	m_pModBusOper = new CModBusOper(m_pDevDataRob->m_sRobotIp, m_pDevDataRob->m_sRobotPort.toInt());  //创建modbus操作对象
	m_nCtrCmdCurr = enCNoCmd;
	m_nOldObstacleValue = 0;
	m_bPlcState = false;
	m_bFrist = true;
}


CRobCtrOper::~CRobCtrOper()
{
	if (m_pModBusOper)
	{
		m_pModBusOper->threadStop();
		m_pModBusOper->deleteLater();
		m_pModBusOper = nullptr;
	}
}

bool CRobCtrOper::ctrDevice(SCtrInfo &stCtrInfo)
{
	int nCmd = stCtrInfo.m_nCtrCmd;
	bool bResult = false;
	SDevExecLog sDevExecLog;
	sDevExecLog.m_sDevName = A2T("机器人");
	//急停命令 直接执行
	if (nCmd == enCSuddenStop)
	{
		bResult = suddenStop(stCtrInfo);
		m_nCtrCmdCurr = 0;  //清空命令
		sDevExecLog.m_bExecResult = bResult;
		sDevExecLog.m_sDescriptionl = stCtrInfo.m_sReData;
		if (!bResult)
		{
			sDevExecLog.m_nAlarmLevel = enDevAlarm;
		}
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		return bResult;
	}

	if (nCmd == enCSuddenStopReset)
	{
		bResult = suddenStop(stCtrInfo);
		m_nCtrCmdCurr = 0;  //清空命令
		sDevExecLog.m_bExecResult = bResult;
		sDevExecLog.m_sDescriptionl = stCtrInfo.m_sReData;
		if (!bResult)
		{
			sDevExecLog.m_nAlarmLevel = enDevAlarm;
		}
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		return bResult;
	}
	//模式切换  手动遥控模式
	if (nCmd == enCWitchModeManual)
	{
		bResult = changeMode(stCtrInfo, 0);    //往PLC写手动遥控模式
		m_nCtrCmdCurr = 0;  //清空命令
		sDevExecLog.m_bExecResult = bResult;
		sDevExecLog.m_sDescriptionl = stCtrInfo.m_sReData;
		if (!bResult)
		{
			sDevExecLog.m_nAlarmLevel = enDevAlarm;
		}
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		return bResult;
	}
	//模式切换  自动任务模式
	if (nCmd == enCWitchModeAuto)
	{
		bResult = changeMode(stCtrInfo, 1);   //往PLC写自动任务模式
		m_nCtrCmdCurr = 0;  //清空命令
		sDevExecLog.m_bExecResult = bResult;
		sDevExecLog.m_sDescriptionl = stCtrInfo.m_sReData;
		if (!bResult)
		{
			sDevExecLog.m_nAlarmLevel = enDevAlarm;
		}
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		return bResult;
	}
	if (m_pDevDataRob->m_nRobRunMode == 2)
	{
		sDevExecLog.m_bExecResult = bResult;
		sDevExecLog.m_sDescriptionl = A2T("维护模式命令不执行，请先切换模式。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		return bResult;
	}
	switch (nCmd)
	{
	case enCNoCmd:          //无命令
	{
		bResult = moveStopRun(stCtrInfo);
	}
	break;
	case enCMoveForward:    //前进
	{
		bResult = moveForward(stCtrInfo);
	}
	break;
	case enCMoveBackward:   //后退
	{
		bResult = moveBackward(stCtrInfo);
	}
	break;
	case enCSetSpeed:       //调速
	{
		bResult = setSpeed(stCtrInfo);
	}
	break;
	case enCStartCharging:  //一键充电
	{
		bResult = startCharging(stCtrInfo);
	}
	break;
	case enCStopCharge:     //手动停止充电
	{
		bResult = stopCharging(stCtrInfo);
	}
	break;
	case enCMoveToPosition: //运动到指定点
	{
		bResult = moveToPosition(stCtrInfo);
	}
	break;
	case enCinitRob:         //位置初始化(一键回零)
	{
		bResult = initRob(stCtrInfo);
	}
	break;
	case enCMoveUp:          //上升
	{
		bResult = moveUp(stCtrInfo);
	}
	break;
	case enCMoveDown:        //下降  
	{
		bResult = moveDown(stCtrInfo);
	}
	break;
	case enCSetSpeedZ:       //Z调速
	{
		bResult = setSpeedZ(stCtrInfo);
	}
	break;
	case enCMoveToPositionZ: //Z运动到指定点
	{
		bResult = moveToPositionZ(stCtrInfo);
	}
	break;
	case enCinitRobZ:        //Z位置初始化(一键回零)
	{
		bResult = initRobZ(stCtrInfo);
	}
	break;
	case enCForceCharge:     //手动强制充电
	{
		bResult = forceCharge(stCtrInfo);
	}
	break;
	case enCManuForceUp:     //手动强制上升Z
	{
		bResult = manualRunUp(stCtrInfo);
	}
	break;
	case enCManuForceDown:   //手动强制下降Z
	{
		bResult = manualRunDown(stCtrInfo);
	}
	break;
	case enCResetAlarmEn:   //报警复位写1
	{
		bResult = resetAlarm(stCtrInfo, 1);
	}
	break;
	case enCResetAlarmOff:  //报警复位写0
	{
		bResult = resetAlarm(stCtrInfo, 0);
	}
	break;
	case enCColseBrakeEn:  //合闸写1
	{
		bResult = closeBrake(stCtrInfo, 1);
	}
	break;
	case enCColseBrakeOff:  //合闸写0
	{
		bResult = closeBrake(stCtrInfo, 0);
	}
	break;
	case enCReleseBrakeEn:  //分闸写1
	{
		bResult = releseBrake(stCtrInfo, 1);
	}
	break;
	case enCReleseBrakeOff:  //合闸写0
	{
		bResult = releseBrake(stCtrInfo, 0);
	}
	break;
	case enCLabelModeEn:  //标签模式写1
	{
		bResult = setLabelMode(stCtrInfo, 1);
	}
	break;
	case enCLabelModeOff:  //标签模式写0
	{
		bResult = setLabelMode(stCtrInfo, 0);
	}
	break;
	case enCLabelResetEn:  //标签复位写1
	{
		bResult = setLabelReset(stCtrInfo, 1);
	}
	break;
	case enCLabelResetOff:  //标签复位写0
	{
		bResult = setLabelReset(stCtrInfo, 0);
	}
	break;
	case enCMotorZeroClearEn:  //电机清零写1
	{
		bResult = motorZeroClear(stCtrInfo, 1);
	}
	break;
	case enCMotorZeroClearOff:  //电机清零写0
	{
		bResult = motorZeroClear(stCtrInfo, 0);
	}
	break;
	case enCManualConfirmEn:  //手动确认写1
	{
		bResult = manualConfirm(stCtrInfo, 1);
	}
	break;
	case enCManualConfirmOff:  //手动确认写0
	{
		bResult = manualConfirm(stCtrInfo, 0);
	}
	break;
	case enCAutoConfirmEn:   //自动确认写1
	{
		bResult = autoConfirm(stCtrInfo, 1);
	}
	break;
	case enCAutoConfirmOff:  //自动确认写0
	{
		bResult = autoConfirm(stCtrInfo, 0);
	}
	break;
	case enCReadPlcCfg:  //读参数
	{
		bResult = readRobCfg(stCtrInfo);
	}
	break;
	case enCWritePlcCfg:  //读参数
	{
		bResult = writePlcValue(stCtrInfo);
	}
	break;
	case enCGoToFlushEn:  //一键冲洗写1
	{
		bResult = writePlcValue(stCtrInfo);
	}
	break;
	case enCGoToFlushOff:  //一键冲洗写0
	{
		bResult = gotoFlush(stCtrInfo, 0);
	}
	break;
	case enCAlarmRemain:  //报警停留
	{
		bResult = alarmRemain(stCtrInfo, 1);
	}
	break;
	case enCResetWorkState: //复位工作状态
	{
		bResult = resetWorkState(stCtrInfo);
	}
	break;
	case enCSave: //保存
	{
		bResult = isSave(stCtrInfo, 1);
	}
	break;
	case enCDisSave: //不保存
	{
		bResult = isSave(stCtrInfo, 0);
	}
	break;
	case enCDirectionCorrect: //方向选择正
	{
		bResult = directionSelect(stCtrInfo, 0);
	}
	break;
	case enCDirectionReverse: //方向选择反
	{
		bResult = directionSelect(stCtrInfo, 1);
	}
	break;
	case enCParameterDistribut: //参数下发
	{
		bResult = ParameterDistribut(stCtrInfo, 1);
	}
	break;
	case enCDisParameterDistribut: //参数不下发
	{
		bResult = ParameterDistribut(stCtrInfo, 0);
	}
	break;
	case enExecItem:        //执行巡检项  
		bResult = true;
		break;
	case enCExecTask:
		bResult = execTask(stCtrInfo);
		break;
	case enCSuspendTask:
		bResult = suspendTask(stCtrInfo);
		break;
	case enCRestartTask:
		bResult = restartTask(stCtrInfo);
		break;
	case enCAbortTask:
		bResult = abortTask(stCtrInfo);
		break;
	default:
	{
		bResult = true;
	}
	break;
	}
	m_nCtrCmdCurr = 0;  //清空命令

	sDevExecLog.m_bExecResult = bResult;
	sDevExecLog.m_sDescriptionl = stCtrInfo.m_sReData;
	if (!bResult)
	{
		sDevExecLog.m_nAlarmLevel = enDevAlarm;
	}
	m_pDevDataRob->addDevExecLog(sDevExecLog);
	return bResult;
}

bool CRobCtrOper::getRobDevData()
{
	if (m_pDevDataRob->m_mapAddrDataR.size() <= 0)
	{
		return false;
	}
	//int nAddr = m_pDevDataRob->m_mapAddrDataR.begin().value().m_sAddrData.toInt();
	int nAddr = m_pDevDataRob->m_mapAddrDataR.first().m_sAddrData.toInt();//取到起始地址
	int nLength = m_pDevDataRob->m_mapAddrDataR.last().m_sAddrData.toInt() + m_pDevDataRob->m_mapAddrDataR.last().m_nAddrLength - nAddr;
	QVector<int> vecReVal;

	if (m_pModBusOper->ReadValEx(nAddr, 80, vecReVal))
	{
		//首先判断PLC连接状态是否从断线后恢复
		if (m_bPlcState == false && !m_bFrist)
		{
			SDevExecLog sDevExecLog;
			sDevExecLog.m_sDevName = A2T("机器人");
			sDevExecLog.m_nAlarmLevel = enAlarmRecovery;
			sDevExecLog.m_sDescriptionl = A2T("PLC连接恢复");
			sDevExecLog.m_dLogTime = QDateTime::currentDateTime();
			sDevExecLog.m_bExecResult = true;
			m_pDevDataRob->addDevExecLog(sDevExecLog);
		}
		m_bPlcState = true;
		if (m_bFrist)
		{
			m_bFrist = false;
		}
		m_pDevDataRob->m_pMutex->lock();
		m_nErrCount = 0;
		m_pDevDataRob->m_bPlcConnectState = true;//PLC连接状态
		SetAddrData(vecReVal,2);
		m_pDevDataRob->m_sDevStatus=(QString::number(m_pDevDataRob->m_mapAddrDataR[enRDevStatus].m_nTagVal));	                   //机器人状态 设备报警状态代码
		m_pDevDataRob->m_sDevWorkStatus=(QString::number(m_pDevDataRob->m_mapAddrDataR[enRDevWorkStatus].m_nTagVal));               //机器人工作状态
		m_pDevDataRob->m_sRobBatteryInfo=(QString::number((double)m_pDevDataRob->m_mapAddrDataR[enRRobBatteryInfo].m_nTagVal / 100));             //机器人电量信息
		m_pDevDataRob->m_sBatteryVol=(QString::number((double)m_pDevDataRob->m_mapAddrDataR[enRBatteryVol].m_nTagVal / 100));                     //机器人电池电压信息
		m_pDevDataRob->m_sRobTempInfo=(QString::number(m_pDevDataRob->m_mapAddrDataR[enRRobTempInfo].m_nTagVal));                   //机器人电池温度信息
		//m_pDevDataRob->m_sRobCurrLoca=(QString::number(m_pDevDataRob->m_mapAddrDataR[enRRobCurrLoca].m_nTagVal));                 //机器人当前位置
		m_pDevDataRob->m_sTaskErr=(QString::number(m_pDevDataRob->m_mapAddrDataR[enRTaskErr].m_nTagVal));                           //机器人执行任务异常说明
		m_pDevDataRob->m_nLightStatus = m_pDevDataRob->m_mapAddrDataR[enRLightStatus].m_nTagVal;									   //三色灯
		m_pDevDataRob->m_sIsInFlushPlace=(QString::number(m_pDevDataRob->m_mapAddrDataR[enRIsInFlushPlace].m_nTagVal));			   //是否到达冲洗位置
		double dAtcDecibel = (double)m_pDevDataRob->m_mapAddrDataR[enRSensorVoice].m_nTagVal / 10 + m_pDevDataRob->m_nVoiceOffset;
		//if (m_pDevDataRob->m_nVoiceAverigeTime == 0)
		//{
		//	m_pDevDataRob->m_pDevDataCam->m_dAtcDecibel = dAtcDecibel;
		//}
		//else
		//{
		//	m_listVoiceDataQueue.append(dAtcDecibel);
		//	if (m_listVoiceDataQueue.size() > m_pDevDataRob->m_nVoiceAverigeTime)
		//	{
		//		m_listVoiceDataQueue.removeFirst();
		//	}
		//	double sum = 0;
		//	for (double value : m_listVoiceDataQueue)
		//	{
		//		sum += value;
		//	}
		//	double average = sum / m_listVoiceDataQueue.size();  // 使用当前队列的大小进行计算
		//	m_pDevDataRob->m_pDevDataCam->m_dAtcDecibel = average;
		//}

		int nTemp = 0;
		//机器人当前位置
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRRobCurrLoca].m_nTagVal;
		//if (nTemp > 30000)//Modifywxy20240517 机器人位置大于30000(30m)也要能正常识别
		//{
			//nTemp -= 65536;
		//}
		m_pDevDataRob->m_sRobCurrLoca=(QString::number(nTemp));//机器人电池电流
		//电池电流
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRBatteryCurr].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sBatteryCurr=(QString::number((double)nTemp / 100));//机器人电池电流

		//机器人电流信息 addwxy 需要处理负数
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRMotorCurr].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sMotorCurr=(QString::number(nTemp));//机器人电机电流

		//运行总里程
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRTotalDis].m_nTagVal;
		m_pDevDataRob->m_sTotalDis=(QString::number((double)nTemp / 10));//机器人运行总里程

		//9.机器人当前速度
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRRobCurrSpeed].m_nTagVal;
		if (nTemp > 4000000000)
		{
			nTemp = 4294967296 - nTemp;
		}
		m_pDevDataRob->m_sRobCurrSpeed=(QString::number(double(nTemp) / 1000));//机器人当前速度

		//10.机器人Z轴位置
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRRobCurrLocaZ].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = 65536 - nTemp;
		}
		m_pDevDataRob->m_sRobCurrLocaZ=(QString::number(nTemp));                 //机器人当前z轴位置

		 //13.机器人电机力矩
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRMotorTorque].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sMotorTorque=(QString::number(nTemp));                   //机器人电机力矩

		//14.机器人电机温度
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRMotorTemp].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sMotorTemp=(QString::number(nTemp));                       //机器人电机温度

		//15.电机报警代码
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRMotorErr].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sMotorErr=(QString::number(nTemp));                         //机器人电机当前报警代码


		//新增检测开关状态
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRSwitchStateCheck].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sSwitchStateCheck=(QString::number(nTemp));         //机器人检测开关状态

		//18.升降电机力矩
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRLiftTorque].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sLiftTorque=(QString::number(nTemp));                     //机器人升降机力矩

		//19.升降机驱动器温度
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRLiftTemp].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sLiftTemp=(QString::number(nTemp));                     //机器人升降机温度

		//20.升降机电机当前报警代码
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRLiftErr].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sLiftErr=(QString::number(nTemp));                           //机器人升降机异常编码

		//21.读取温度
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRSensorTemp].m_nTagVal + m_pDevDataRob->m_nTempOffset;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sSensorTemp=(QString::number(double(nTemp / 10)));                     //机器人传感器温度

		//22.读取湿度
		if (m_pDevDataRob->m_nHumEnable == 1)
		{
			nTemp = m_pDevDataRob->m_mapAddrDataR[enRSensorHum].m_nTagVal + m_pDevDataRob->m_nHumOffset;
			if (nTemp > 30000)
			{
				nTemp = nTemp - 65536;
			}
			m_pDevDataRob->m_sSensorHum=(QString::number(double(nTemp) / 10));                       //机器人传感器湿度
		}
		else
		{
			m_pDevDataRob->m_sSensorHum=(QString::number(0));                       //机器人传感器湿度
		}

		//23.读取pm2.5
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRSensorPM25].m_nTagVal + m_pDevDataRob->m_nPM25Offset;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sSensorPM25=(QString::number(nTemp));                     //机器人传感器PM2.5

		//24.读取pm10
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRSensorPM10].m_nTagVal + m_pDevDataRob->m_nPM10Offset;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sSensorPM10=(QString::number(nTemp));                      //机器人传感器PM10
		//25.读取可燃气体
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRSensorGas].m_nTagVal + m_pDevDataRob->m_nGasOffset;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_sSensorGas=(QString::number(nTemp));                       //机器人传感器可燃气体
		//26.Co一氧化碳
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRSensorCO].m_nTagVal + m_pDevDataRob->m_nCoOffset;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		if (nTemp < 0)
		{
			nTemp = 0;
		}
		m_pDevDataRob->m_sSensorCO=(QString::number(nTemp));                         //机器人传感器一氧化碳

		//RFID标签值(序号)
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRRfidTagNum].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sRfidTagNum=(QString::number(nTemp));                     //机器人Rfid标签序号

		//RFID标签位置值(单位0.1m)
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRRfidTagVal].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp -= 65536;
		}
		m_pDevDataRob->m_sRfidTagVal=(QString::number(nTemp));                     //机器人Rfid标签值

		//31.机器人执行任务状态
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRTaskStatus].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_nTaskStatus = nTemp;                                           //机器人当前任务状态

		//31.读取机器人执行巡检项序号
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRPolItemNum].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_nPolItemNum = nTemp;                                         //机器人当前巡检项序号

		//32.读取巡检项执行结果
		nTemp = m_pDevDataRob->m_mapAddrDataR[enRPolItemExecStatus].m_nTagVal;
		if (nTemp > 30000)
		{
			nTemp = nTemp - 65536;
		}
		m_pDevDataRob->m_nPolItemExecStatus = nTemp;                           //当前巡检项执行状态
		m_pDevDataRob->m_pMutex->unlock();
	}
	else
	{
		m_nErrCount++;
		if (m_nErrCount > 20)//断线10秒钟才算掉线
		{
			m_bPlcState = false;
			m_bFrist = false;
			SDevExecLog sDevExecLog;
			sDevExecLog.m_sDevName = A2T("机器人");
			sDevExecLog.m_nAlarmLevel = enDevAlarm;
			sDevExecLog.m_sDescriptionl = A2T("PLC网络连接异常，请检查网络是不是正常。");
			sDevExecLog.m_dLogTime = QDateTime::currentDateTime();
			sDevExecLog.m_bExecResult = false;
			m_pDevDataRob->addDevExecLog(sDevExecLog);
			m_pDevDataRob->m_bPlcConnectState = false;
			m_nErrCount = 0;
		}
		return false;
	}

	/**
	* @ Author: Gaojia
	* @ Description:  计算托辊号
	*/
	//int nBelogn = m_pDevDataRob->m_nBelogn;
	//float fLocation = m_pDevDataRob->m_sRobCurrLoca.get().toFloat() / 1000;      //当前位置
	//m_pDevDataRob->m_nRollerNum = m_pDevDataRob->getRollerNoEx(fLocation, m_pDevDataRob->m_sRollerDesc, nBelogn);

	//{
	//	sysSleepTime(50);
	//	//读取写地址中的数据
	//	int nAddrW = m_pDevDataRob->m_mapAddrDataW.first().m_sAddrData.toInt();//取到起始地址
	//	int nLength = m_pDevDataRob->m_mapAddrDataW.last().m_sAddrData.toInt() + m_pDevDataRob->m_mapAddrDataW.last().m_nAddrLength - nAddrW;
	//	QVector<int> vecReValW;
	//	if (m_pModBusOper->ReadValEx(nAddrW, nLength, vecReValW))
	//	{
	//		SetAddrDataW(vecReValW);

	//		m_pDevDataRob->m_nRobRunMode = m_pDevDataRob->m_mapAddrDataW[enWRunModelFlag].m_nTagVal;//当前机器人处于的模式
	//		m_pDevDataRob->m_dRobRunSpeedSet=(QString::number((double)m_pDevDataRob->m_mapAddrDataW[enWRobSpeedSet].m_nTagVal / 1000));//设定速度
	//		m_pDevDataRob->m_nLabelMode = m_pDevDataRob->m_mapAddrDataW[enWTagWModeOnOff].m_nTagVal;
	//		m_pDevDataRob->m_nDirectionSelect = m_pDevDataRob->m_mapAddrDataW[enWDirectionSelect].m_nTagVal;
	//		m_pDevDataRob->m_nParameterdDistribut = m_pDevDataRob->m_mapAddrDataW[enWParameterDistribut].m_nTagVal;
	//		m_pDevDataRob->m_nSave = m_pDevDataRob->m_mapAddrDataW[enWSave].m_nTagVal;
	//	}
	//}

	//读取冲洗设备的实时状态
	//if (m_pDevDataRob->m_nFlushBlong == 1)
	//{
	//	sysSleepTime(50);
	//	int nAddr = m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR.first().m_sAddrData.toInt();//取到起始地址
	//	int nLength = m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR.last().m_sAddrData.toInt() + m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR.last().m_nAddrLength - nAddr;
	//	QVector<int> vecReVal;
	//	if (m_pModBusOper->ReadValEx(nAddr, nLength, vecReVal))
	//	{
	//		m_pDevDataRob->m_pDevDataFlush->m_bPlcConnectState = true;//PLC连接状态
	//		SetAddrDataFlush(vecReVal);
	//		m_pDevDataRob->m_pDevDataFlush->m_sDevStatus=(QString::number(m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushDevState].m_nTagVal));
	//		m_pDevDataRob->m_pDevDataFlush->m_sDevWorkStatus=(QString::number(m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushWorkStatus].m_nTagVal));
	//		m_pDevDataRob->m_pDevDataFlush->m_sCtrCmdExecRe=(QString::number(m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushCtrCmdExecRe].m_nTagVal));
	//		m_pDevDataRob->m_pDevDataFlush->m_sPilotLamp=(QString::number(m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushPilotLamp].m_nTagVal));

	//		int nTemp;
	//		nTemp = m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushOutletFlow].m_nTagVal;
	//		if (nTemp > 30000)
	//		{
	//			nTemp -= 65536;
	//		}
	//		m_pDevDataRob->m_pDevDataFlush->m_sOutletFlow=(QString::number(nTemp));

	//		nTemp = m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushInletPressure].m_nTagVal;
	//		if (nTemp > 30000)
	//		{
	//			nTemp -= 65536;
	//		}
	//		m_pDevDataRob->m_pDevDataFlush->m_sInletPressure=(QString::number(nTemp));

	//		nTemp = m_pDevDataRob->m_pDevDataFlush->m_mapAddrDataR[enRFlushOutletPressure].m_nTagVal;
	//		if (nTemp > 30000)
	//		{
	//			nTemp -= 65536;
	//		}
	//		m_pDevDataRob->m_pDevDataFlush->m_sOutletPressure=(QString::number(nTemp));
	//	}
	//}
	return true;
}

void CRobCtrOper::writeCsvLog()
{
	m_pDevDataRob->lock();
	QString sTime = QDateTime::currentDateTime().toString("yyyyMM");
	QString sFontTypePath = QCoreApplication::applicationDirPath();     //根目录
	QString sUrl = sFontTypePath + "/csvLog/" + sTime;
	QString sName = QDateTime::currentDateTime().toString("yyyyMMdd") + m_pDevDataRob->m_sRobName + "RunLog.csv";
	QString sTitle = A2T("时间,PLC连接状态,设备报警故障状态描述,设备报警故障状态码,设备工作状态,总里程(m),电量(%),电池温度(℃),电机温度(℃),机器人位置(m),速度(m/s),湿度(%RH),温度(℃),PM2.5浓度(ug/m3),PM10浓度(ug/m3),可燃气体浓度(ppm),电池电压(V),电池电流(A),电机力矩(%),电机电流(A),Rfid标签值(序号),Rfid标签位置值(m),Z轴位置(m),检测开关状态\r\n");
	QString sData = "";
	sData += QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss") + ",";//时间
	if (m_pDevDataRob->m_bPlcConnectState == false)
	{
		sData += A2T("未连接,");
	}
	else
	{
		sData += A2T("已连接,");
	}
	sData += GetDevAlarmStr(m_pDevDataRob->m_sDevStatus.toLongLong()) + ",";//设备报警故障状态描述
	sData += QString::number(m_pDevDataRob->m_sDevStatus.toLongLong()) + ",";//设备报警故障状态码
	sData += GetDevStateStr(m_pDevDataRob->m_sDevStatus.toLongLong()) + ",";//设备工作状态
	sData += QString::number(((double)m_pDevDataRob->m_sTotalDis.toDouble()), 'f', 2) + ",";//总里程(m)
	sData += QString::number(((double)m_pDevDataRob->m_sRobBatteryInfo.toDouble()), 'f', 2) + ",";//电量(%)
	sData += QString::number(((double)m_pDevDataRob->m_sRobTempInfo.toDouble()), 'f', 2) + ",";//电池温度(℃)
	sData += QString::number(((double)m_pDevDataRob->m_sMotorTemp.toDouble()), 'f', 2) + ",";//电机温度
	sData += QString::number(((double)m_pDevDataRob->m_sRobCurrLoca.toDouble() / 1000), 'f', 2) + ",";//机器人位置(m)
	sData += QString::number(((double)m_pDevDataRob->m_sRobCurrSpeed.toDouble()), 'f', 2) + ",";//速度(m/s)
	sData += QString::number(((double)m_pDevDataRob->m_sSensorHum.toDouble()), 'f', 2) + ",";//湿度(%RH)
	sData += QString::number(((double)m_pDevDataRob->m_sSensorTemp.toDouble()), 'f', 2) + ",";//温度(℃)
	sData += QString::number(((double)m_pDevDataRob->m_sSensorPM25.toDouble()), 'f', 2) + ",";//PM2.5浓度(ug/m3)
	sData += QString::number(((double)m_pDevDataRob->m_sSensorPM10.toDouble()), 'f', 2) + ",";//PM10浓度(ug / m3)
	sData += QString::number(((double)m_pDevDataRob->m_sSensorCO.toDouble()), 'f', 2) + ",";//可燃气体浓度(ppm)
	sData += QString::number(((double)m_pDevDataRob->m_sBatteryVol.toDouble()), 'f', 2) + ",";//电池电压(V)
	sData += QString::number(((double)m_pDevDataRob->m_sBatteryCurr.toDouble()), 'f', 2) + ",";//电池电流(A)
	sData += QString::number(((double)m_pDevDataRob->m_sMotorTorque.toDouble()), 'f', 2) + ",";//电机力矩(%)
	sData += QString::number(((double)m_pDevDataRob->m_sMotorCurr.toDouble()), 'f', 2) + ",";//电机电流(A)
	sData += QString::number(((double)m_pDevDataRob->m_sRfidTagNum.toDouble()), 'f', 2) + ",";//Rfid标签值(序号)
	sData += QString::number(((double)m_pDevDataRob->m_sRfidTagVal.toDouble()), 'f', 2) + ",";////Rfid标签位置值(m)
	sData += QString::number(((double)m_pDevDataRob->m_sRobCurrLocaZ.toDouble() / 1000), 'f', 3) + ",";//Z轴位置值(m)
	if (m_pDevDataRob->m_sSwitchStateCheck.toInt() == 0)//检测开关状态
	{
		sData += A2T("无信号\r\n");
	}
	else
	{
		sData += A2T("有信号\r\n");
	}
	m_pDevDataRob->unLock();
	saveCsvData(sUrl, sName, sData, sTitle);
}

void CRobCtrOper::initModBus()
{
}

bool CRobCtrOper::moveForward(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCMoveForward);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("前进命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("前进命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
	return true;
}

bool CRobCtrOper::moveBackward(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCMoveBackward);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("后退命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("后退命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::moveUp(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCMoveUp);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("机械臂上升命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("机械臂上升命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::moveDown(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCMoveDown);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("机械臂下降命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("机械臂下降命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::moveStopRun(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCNoCmd);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("停止命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("停止命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::suddenStop(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCSuddenStop, -1);   //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		nReVal = getCtrCmdExecResult(enCSuddenStop);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("急停命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData(1);   //复位命令
			sReInfo = sReInfo + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("急停命令执行失败") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("急停命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::setSpeed(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCSetSpeed, enWRobSpeedSet, stCtrInfo.m_nSpeed * 100);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		nReVal = getCtrCmdExecResult(enCSetSpeed);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("调速到%1m/s命令:").arg((double)stCtrInfo.m_nSpeed / 10) + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("调速命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("调速命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::initRob(SCtrInfo & stCtrInfo)
{
	int nReVal = execCmd(enCinitRob, -1);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("复位指令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		nReVal = waitForExecResult(enCinitRob);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("位置初始化命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("位置初始化命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("位置初始化命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::startCharging(SCtrInfo &stCtrInfo)
{
	int nReVal = execCmd(enCStartCharging, -1);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("充电指令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		nReVal = waitForExecResult(enCStartCharging);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("一键充电命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("一键充电命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("一键充电命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::stopCharging(SCtrInfo& stCtrInfo)
{
	int nReVal = execCmd(enCStopCharge, -1);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("停止充电指令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		nReVal = waitForExecResult(enCStopCharge);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("停止充电命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("停止充电命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("停止充电命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::forceCharge(SCtrInfo &stCtrInfo)
{
	int nReVal = execCmd(enCForceCharge);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("手动强制充电命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("手动强制充电命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
	return false;
}

bool CRobCtrOper::moveToPosition(SCtrInfo &stCtrInfo)
{
	int nReVal = execCmd(enCMoveToPosition, enWMoveLocaVal, stCtrInfo.m_nLocaVal);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("运动到") + QString::number((double)stCtrInfo.m_nLocaVal / 1000, 'f', 1) + A2T("位置指令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		nReVal = waitForExecResult(enCMoveToPosition);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("运动到指定位置命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("运动到指定位置命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("运动到指定位置命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::moveToPositionZ(SCtrInfo& stCtrInfo)
{
	int nReVal = execCmd(enCMoveToPositionZ, enWMoveLocaValZ, stCtrInfo.m_nLocaVal);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("升降机运动到") + QString::number((double)stCtrInfo.m_nLocaVal / 1000, 'f', 1) + A2T("位置指令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		nReVal = waitForExecResult(enCMoveToPositionZ);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("升降机运动到指定位置命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("运动到指定位置命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("运动到指定位置命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::setSpeedZ(SCtrInfo& stCtrInfo)
{
	int nReVal = execCmd(enCSetSpeedZ, enWRobSpeedSetZ, stCtrInfo.m_nSpeed * 100);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		nReVal = getCtrCmdExecResult(enCSetSpeedZ);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("升降机调速命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("升降机调速命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("升降机调速命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::initRobZ(SCtrInfo& stCtrInfo)
{
	int nReVal = execCmd(enCinitRobZ, -1);    //执行命令
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("升降机复位指令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		nReVal = waitForExecResult(enCinitRobZ);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("升降机位置初始化命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			nReVal = resetExecData();   //复位命令
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("升降机位置初始化命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("升降机位置初始化命令执行失败:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::manualRunUp(SCtrInfo& stCtrInfo)
{
	int nReVal = execCmd(enCManuForceUp);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("手动强制上升命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("手动强制上升命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::manualRunDown(SCtrInfo& stCtrInfo)
{
	int nReVal = execCmd(enCManuForceDown);
	QString sReInfo = m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("前进命令") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("前进命令执行失败") + sReInfo;
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::resetAlarm(SCtrInfo & stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWAlarmRes, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("报警复位-写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("报警复位-写") + QString::number(nResrt) + A2T("失败") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}


bool CRobCtrOper::execTask(SCtrInfo &stCtrInfo)
{

	QString sReInfo = "";
	int nReVal = writeData(stCtrInfo.m_vecArray, stCtrInfo.m_vecIndex);
	//1.执行任务写数据
	if (nReVal != enSuccess)
	{
		sReInfo = A2T("执行任务") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
	//2.执行命令
	nReVal = execCmdEx(enCExecTask, enWTaskCmd, -1);
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("开始执行任务命令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		//3.等待命令执行结果
		nReVal = waitForTaskExecResult(enCExecTask);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("开始执行任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			//4.复位命令
			nReVal = resetTaskExecData();
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("开始执行任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			//此时需将刚才写的40082复位,hjx++
			if (writeData(enWTaskCmd, 0) == enWriteParamFail)
			{
				sReInfo += A2T(" 复位执行任务命令失败");
			}
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("开始任务命令") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::suspendTask(SCtrInfo &stCtrInfo)
{
	QString sReInfo = "";
	//1.执行命令
	int nReVal = execCmdEx(enCSuspendTask, enWTaskCmd, -1);
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("暂停执行任务命令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		//2.等待命令执行结果
		nReVal = waitForTaskExecResult(enCSuspendTask);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("暂停执行任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			//4.复位命令
			nReVal = resetTaskExecData();
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("暂停执行任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("暂停执行任务命令") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::restartTask(SCtrInfo &stCtrInfo)
{
	QString sReInfo = "";
	//1.执行命令
	int nReVal = execCmdEx(enCRestartTask, enWTaskCmd, -1);
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("恢复任务命令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		//2.等待命令执行结果
		nReVal = waitForTaskExecResult(enCRestartTask);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("恢复任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			//4.复位命令
			nReVal = resetTaskExecData();
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("恢复任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("恢复任务命令") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::abortTask(SCtrInfo &stCtrInfo)
{
	QString sReInfo = "";
	//1.执行命令
	int nReVal = execCmdEx(enCAbortTask, enWTaskCmd, -1);
	if (nReVal == enSuccess)
	{
		bool bResult = false;
		SDevExecLog sDevExecLog;
		sDevExecLog.m_sDevName = A2T("机器人");
		sDevExecLog.m_sDescriptionl = A2T("中止执行任务命令下发成功。");
		m_pDevDataRob->addDevExecLog(sDevExecLog);
		//2.等待命令执行结果
		nReVal = waitForTaskExecResult(enCAbortTask);
		if (nReVal == enSuccess)
		{
			sReInfo = A2T("中止执行任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			//4.复位命令
			nReVal = resetTaskExecData();
			sReInfo = sReInfo + A2T("，复位状态:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return true;
		}
		else
		{
			sReInfo = A2T("中止执行任务命令:") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
			stCtrInfo.m_sReData = sReInfo;
			return false;
		}
	}
	else
	{
		sReInfo = A2T("中止执行任务命令") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::changeMode(SCtrInfo & stCtrInfo, int nType)
{
	int nReVal = writeData(enWRunModelFlag, nType);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		if (nType == 0)
		{
			sReInfo = A2T("切换手动遥控模式成功");
			m_pDevDataRob->m_nRobRunMode = 0;

		}
		else
		{
			sReInfo = A2T("切换自动任务模式成功");
			m_pDevDataRob->m_nRobRunMode = 1;
		}
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		if (nType == 0)
		{
			sReInfo = A2T("切换手动遥控模式失败") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);;

		}
		else
		{
			sReInfo = A2T("切换自动任务模式失败") + m_pDevDataRob->getCtrCmdExecReInfo(nReVal);;
		}
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::gotoFlush(SCtrInfo & stCtrInfo, int nVal)//一键冲洗
{
	int nReVal = writeData(enWMoveToFlush, nVal);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("一键冲洗") + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("一键冲洗") + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::alarmRemain(SCtrInfo& stCtrInfo, int nVal)
{
	int nReVal = writeData(enWAlarmStop, nVal);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("报警停留") + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("报警停留") + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::resetWorkState(SCtrInfo& stCtrInfo)//复位工作状态
{
	int nRet;
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRDevWorkStatus].m_sAddrData.toInt(), 0) == true)
	{
		nRet = enSuccess;
	}
	else
	{
		nRet = enWriteParamFail;
	}
	QString sReInfo = "";
	if (nRet == enSuccess)
	{
		sReInfo = A2T("复位工作状态") + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("复位工作状态") + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::closeBrake(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWSwitchClose, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("合闸写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("合闸写") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::releseBrake(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWSwitchOpen, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("分闸写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("分闸写") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::setLabelMode(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWTagWModeOnOff, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("标签模式") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("标签模式") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::setLabelReset(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWTagWModeReset, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("标签复位写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("标签复位写") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::motorZeroClear(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWTagWModeMotorZero, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("电机清零写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("电机清零写") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::manualConfirm(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWTagWModeAccep, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("手动确认写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("手动确认写") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::autoConfirm(SCtrInfo& stCtrInfo, int nResrt)
{
	int nReVal = writeData(enWTagWModeAutoEn, nResrt);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("自动确认写") + QString::number(nResrt) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("自动确认写") + QString::number(nResrt) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::directionSelect(SCtrInfo& stCtrInfo, int nVal)
{
	int nReVal = writeData(enWDirectionSelect, nVal);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("方向选择写") + QString::number(nVal) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("方向选择写") + QString::number(nVal) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::ParameterDistribut(SCtrInfo& stCtrInfo, int nVal)
{
	int nReVal = writeData(enWParameterDistribut, nVal);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("参数下发写") + QString::number(nVal) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("参数下发写") + QString::number(nVal) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::isSave(SCtrInfo& stCtrInfo, int nVal)
{
	int nReVal = writeData(enWSave, nVal);
	QString sReInfo = "";
	if (nReVal == enSuccess)
	{
		sReInfo = A2T("是否保存写") + QString::number(nVal) + A2T("成功");
		stCtrInfo.m_sReData = sReInfo;
		return true;
	}
	else
	{
		sReInfo = A2T("是否保存写") + QString::number(nVal) + A2T("失败");
		stCtrInfo.m_sReData = sReInfo;
		return false;
	}
}

bool CRobCtrOper::readRobCfg(SCtrInfo& stCtrInfo)
{
	int nAddr = m_pDevDataRob->m_mapAddrDataW[1].m_sAddrData.toInt();//取到起始地址
	int nLength = m_pDevDataRob->m_mapAddrDataW.last().m_sAddrData.toInt() + m_pDevDataRob->m_mapAddrDataW.last().m_nAddrLength - nAddr;
	QVector<int> vecReVal;
	if (m_pModBusOper->ReadValExLoop(nAddr, nLength, vecReVal))
	{
		m_pDevDataRob->m_bPlcConnectState = true;//PLC连接状态
		SetAddrData(vecReVal,1,1);
		m_pDevDataRob->m_dRobRunSpeed = m_pDevDataRob->m_mapAddrDataW[enWRobSpeedSet].m_nTagVal;//机器人主机运行速度(默认行走速度)
		m_pDevDataRob->m_dRobRunSpeedZ = m_pDevDataRob->m_mapAddrDataW[enWRobSpeedSetZ].m_nTagVal;//机器人主机运行速度Z
		m_pDevDataRob->m_nRobWorkType = m_pDevDataRob->m_mapAddrDataW[enWRunModelFlag].m_nTagVal;//机器人工作模式  0 遥控模式 1 自动任务模式
		m_pDevDataRob->m_nProximitySensorOffset = m_pDevDataRob->m_mapAddrDataW[enWProSensorOffset].m_nTagVal;//接近传感器偏移量
		m_pDevDataRob->m_nNo2LabelOffset = m_pDevDataRob->m_mapAddrDataW[enWTag2Offset].m_nTagVal;//#2标签偏移量
		m_pDevDataRob->m_nIsOpenAutoCharge = m_pDevDataRob->m_mapAddrDataW[enWLowBatteryAutoChargeEn].m_nTagVal;//是否开启低电量自动充电
		m_pDevDataRob->m_dReturnSpeed = m_pDevDataRob->m_mapAddrDataW[enWLowBatteryAutoChargeEn].m_nTagVal;//是否开启低电量自动充电
		m_pDevDataRob->m_dFrontObstacleAvoidance = m_pDevDataRob->m_mapAddrDataW[enWFrontObsDis].m_nTagVal;//前避障距离
		m_pDevDataRob->m_dBackObstanceAvidance = m_pDevDataRob->m_mapAddrDataW[enWRealObsDis].m_nTagVal;//后避障距离
		m_pDevDataRob->m_dChargeCutOffThreshold = double(m_pDevDataRob->m_mapAddrDataW[enWChargeLimitThre].m_nTagVal) / 100;//充电截止阈值
		m_pDevDataRob->m_dChargeCutOffVolTage = double(m_pDevDataRob->m_mapAddrDataW[enWChargeLimitVol].m_nTagVal) / 100;//充电截止电压
		m_pDevDataRob->m_dHoldingAddPowerThreshold = double(m_pDevDataRob->m_mapAddrDataW[enWStanChargeThre].m_nTagVal) / 100;//待机补电阈值
		m_pDevDataRob->m_dHoldingAddPowerVoltage = double(m_pDevDataRob->m_mapAddrDataW[enWStanChargeVol].m_nTagVal) / 100;//待机补电电压
		m_pDevDataRob->m_dTaskEleQuantityThreshold = double(m_pDevDataRob->m_mapAddrDataW[enWTaskExecPowerThre].m_nTagVal) / 100;//执行任务电量阈值
		m_pDevDataRob->m_dTaskEleQuantityVoltage = double(m_pDevDataRob->m_mapAddrDataW[enWTaskExecPowerVol].m_nTagVal) / 100;//执行任务电量电压
		m_pDevDataRob->m_dForceChargeThreshold = double(m_pDevDataRob->m_mapAddrDataW[enWForceChargeThre].m_nTagVal) / 100;//强制充电阈值
		m_pDevDataRob->m_dForceChargeVoltage = double(m_pDevDataRob->m_mapAddrDataW[enWForceChargeVol].m_nTagVal) / 100;//强制充电电压
		m_pDevDataRob->m_dChargeFallLoopCount = m_pDevDataRob->m_mapAddrDataW[enWChargeFailCyc].m_nTagVal;//充电失败循环次数
		m_pDevDataRob->m_dChargeCommunicationDelay = m_pDevDataRob->m_mapAddrDataW[enWChargerCommDelay].m_nTagVal;//充电通讯延时
		m_pDevDataRob->m_dChargeAutoRetornDistance = double(m_pDevDataRob->m_mapAddrDataW[enWChargeAutoRetreatDis].m_nTagVal) / 100;//充电自动回退距离
		m_pDevDataRob->m_dLevelOneSpeedCut = double(m_pDevDataRob->m_mapAddrDataW[enWFirLevelReduc].m_nTagVal) / 100;//一级减速
		m_pDevDataRob->m_dLevelTwoSpeedCut = double(m_pDevDataRob->m_mapAddrDataW[enWSecLevelReduc].m_nTagVal) / 100;//二级减速
		m_pDevDataRob->m_dDriveMotorUpperCurrent = double(m_pDevDataRob->m_mapAddrDataW[enWMotorCurrLimit].m_nTagVal) / 100;//驱动电机电流上限
		m_pDevDataRob->m_dDriveMotorCurrentSleep = m_pDevDataRob->m_mapAddrDataW[enWMotorCurrDelay].m_nTagVal;//驱动电机电流延时
		m_pDevDataRob->m_dDriveMotorUpperTorque = double(m_pDevDataRob->m_mapAddrDataW[enWMotorTorqueLimit].m_nTagVal) / 100;//驱动电机扭矩上限
		m_pDevDataRob->m_dDriveMotorTorqueSleep = m_pDevDataRob->m_mapAddrDataW[enWMotorTorqueDelay].m_nTagVal;//驱动电机扭矩延时
		m_pDevDataRob->m_dDriveMotorUpperTemp = m_pDevDataRob->m_mapAddrDataW[enWMotorTempLimit].m_nTagVal;//驱动电机温度上限
		m_pDevDataRob->m_dDriveMotorTempSleep = m_pDevDataRob->m_mapAddrDataW[enWMotorTempDelay].m_nTagVal;//驱动电机温度延时
		m_pDevDataRob->m_dLiftMotorUpperCurrent = double(m_pDevDataRob->m_mapAddrDataW[enWLiftMotorCurrLimit].m_nTagVal) / 100;//升降电机电流上限
		m_pDevDataRob->m_dLiftMotorCurrentSleep = m_pDevDataRob->m_mapAddrDataW[enWLiftMotorCurrDelay].m_nTagVal;//升降电机电流延时
		m_pDevDataRob->m_dLiftMotorUpperTorque = double(m_pDevDataRob->m_mapAddrDataW[enWLiftMotorTorqueLimit].m_nTagVal) / 100;//升降电机扭矩上限
		m_pDevDataRob->m_dLiftMotorTorqueSleep = m_pDevDataRob->m_mapAddrDataW[enWLiftMotoTorqueDelay].m_nTagVal;//升降电机扭矩延时
		m_pDevDataRob->m_dLiftMotorUpperTemp = m_pDevDataRob->m_mapAddrDataW[enWLiftMotoTemp].m_nTagVal;//升降电机温度上限
		m_pDevDataRob->m_dLiftMotorTempSleep = m_pDevDataRob->m_mapAddrDataW[enWLiftMotoTempDelay].m_nTagVal;//升降电机温度延时
		m_pDevDataRob->m_dLiftMotorSleepSet = m_pDevDataRob->m_mapAddrDataW[enWLiftSpeed].m_nTagVal;//升降电机速度值设定

		m_pDevDataRob->m_dAutoSwitchOpenBatteryThre = double(m_pDevDataRob->m_mapAddrDataW[enWAutoSwitchOpenBatteryThre].m_nTagVal) / 100;//自动分闸电量阈值
		m_pDevDataRob->m_dAutoSwitchOpenVolThre = double(m_pDevDataRob->m_mapAddrDataW[enWAutoSwitchOpenVolThre].m_nTagVal) / 100;//自动分闸电压阈值
		m_pDevDataRob->m_dIsAutoFlush = m_pDevDataRob->m_mapAddrDataW[enWIsAutoFlush].m_nTagVal;//巡检结束是否冲洗
		m_pDevDataRob->m_nFlushRFID1 = m_pDevDataRob->m_mapAddrDataW[enWFlushRFID1].m_nTagVal;//冲洗位置前RFID号
		m_pDevDataRob->m_nFlushRFID2 = m_pDevDataRob->m_mapAddrDataW[enWFlushRFID2].m_nTagVal;//冲洗位置后RFID号
		m_pDevDataRob->m_dFlushPlaceOffset = m_pDevDataRob->m_mapAddrDataW[enWFlushPlaceOffset].m_nTagVal;//冲洗位置补偿值(mm)
		if (m_pDevDataRob->m_mapAddrDataW[enWFlushPlaceOffset].m_nTagVal > 32767)
		{
			m_pDevDataRob->m_dFlushPlaceOffset = (int)(m_pDevDataRob->m_mapAddrDataW[enWFlushPlaceOffset].m_nTagVal - 65536);//冲洗位置补偿值(mm)
		}
		else
		{
			m_pDevDataRob->m_dFlushPlaceOffset = m_pDevDataRob->m_mapAddrDataW[enWFlushPlaceOffset].m_nTagVal;//冲洗位置补偿值(mm)
		}
		m_pDevDataRob->m_nAlarmStopTime = m_pDevDataRob->m_mapAddrDataW[enWAlarmStopTime].m_nTagVal;//持续检测发生报警时停留时间(s)
		m_pDevDataRob->m_nChargeYTPreset = m_pDevDataRob->m_mapAddrDataW[enWChargeYTPreset].m_nTagVal;//充电云台预置点
		m_pDevDataRob->m_nCollectTime = m_pDevDataRob->m_mapAddrDataW[enWCollectTime].m_nTagVal;//充电云台预置点
		stCtrInfo.m_sReData = A2T("读取机器人PLC参数成功");
		return true;
	}
	else
	{
		stCtrInfo.m_sReData = A2T("读取机器人设备参数失败");
		return false;
	}
}

void CRobCtrOper::SetAddrData(QVector<int>vecReVal, int nIndex, int nType)
{
	if (nType == 0)
	{
		int nAddrStart = m_pDevDataRob->m_mapAddrDataR[nIndex].m_sAddrData.toInt();
		for (QMap<int, SAddrData>::iterator itor = m_pDevDataRob->m_mapAddrDataR.begin(); itor != m_pDevDataRob->m_mapAddrDataR.end(); itor++)
		{
			SAddrData AddrData = itor.value();
			int nAddr = AddrData.m_sAddrData.toInt();
			int nLength = AddrData.m_nAddrLength;
			int nIndexEx = nAddr - nAddrStart;
			quint64 nData = 0;
			for (int j = 0; j < nLength; j++)
			{
				nData = nData * 65536 + vecReVal[nIndexEx + j];
			}
			itor.value().m_nTagVal = nData;
		}
	}
	else
	{
		int nAddrStart = m_pDevDataRob->m_mapAddrDataW[nIndex].m_sAddrData.toInt();
		for (QMap<int, SAddrData>::iterator itor = m_pDevDataRob->m_mapAddrDataW.begin(); itor != m_pDevDataRob->m_mapAddrDataW.end(); itor++)
		{
			SAddrData AddrData = itor.value();
			int nAddr = AddrData.m_sAddrData.toInt();
			int nLength = AddrData.m_nAddrLength;
			int nIndexEx = nAddr - nAddrStart;
			quint64 nData = 0;
			for (int j = 0; j < nLength; j++)
			{
				nData = nData * 65536 + vecReVal[nIndexEx + j];
			}
			itor.value().m_nTagVal = nData;
		}
	}
}

bool CRobCtrOper::writePlcValue(SCtrInfo& stCtrInfo)
{
	if (m_pModBusOper->WriteVal(stCtrInfo.m_nWriteAddr, stCtrInfo.m_nAddrLen, stCtrInfo.m_nValue) == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

/********************************************************************************
*Description:执行控制命令
*FunParameter:控制命令
*FunReturnValue:返回控制命令执行结果信息枚举
*Author:Gaojia
*Date:2024/02/02
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
int CRobCtrOper::execCmd(int nCmd)
{
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWCtrCmd].m_sAddrData.toInt(), nCmd) == true)
	{
		m_nCtrCmdCurr = nCmd;
		return enSuccess;
	}
	else
	{
		return enSetCmdFail;
	}
}


/********************************************************************************
*Description:单个地址写值
*FunParameter:地址序号 和值
*FunReturnValue:返回写值执行结果
*Author:Gaojia
*Date:2024/02/04
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
int CRobCtrOper::writeData(int nAddr, int nData)
{
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[nAddr].m_sAddrData.toInt(), nData) == true)
	{
		return enSuccess;
	}
	else
	{
		return enWriteParamFail;
	}
}

/********************************************************************************
*Description:    执行控制命令 带参数
*FunParameter:   控制命令  设置参数的地址   设置的值
*FunReturnValue: 返回控制命令执行结果信息枚举
*Author:Gaojia
*Date:2024/02/02
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
int CRobCtrOper::execCmd(int nCmd, int nAddr, int nVal)
{
	//遥控模式命令 就是ECCmdType枚举 
	int nCmdEx = nCmd;
	//任务模式命令 601对应1 602对应2 603对应3  604对应4
	if (nCmd >= enCExecTask)
	{
		nCmdEx = nCmd - 600;
	}
	//1.复位执行结果
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRCtrCmdExecStatus].m_sAddrData.toInt(), 0) == false)
	{
		return enResetResultFail;
	}
	//2.如果需要写值 如调速 运动指定点等 写入对应测定数据
	if (nAddr >= 0)
	{
		SAddrData stAddrData = m_pDevDataRob->m_mapAddrDataW[nAddr];
		if (m_pModBusOper->WriteVal(stAddrData.m_sAddrData.toInt(), stAddrData.m_nAddrLength, nVal) == false)
		{
			return enWriteParamFail;
		}
	}
	//3.设置命令
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWCtrCmd].m_sAddrData.toInt(), nCmdEx) == false)
	{
		return enSetCmdFail;
	}
	else
	{
		//4.读取控制命令执行状态点值 判断PLC是否已读命令
		int nReVal = 0;
		if (m_pModBusOper->ReadVal(m_pDevDataRob->m_mapAddrDataR[enRCtrCmdExecRe].m_sAddrData.toInt(), nReVal) == false)
		{
			return enReadFail;
		}
		else
		{
			if (nReVal == nCmd)
			{
				m_nCtrCmdCurr = nCmd;
				return enSuccess;
			}
			else
			{
				return enPlcNoFeedBack;
			}
		}
	}
}

int CRobCtrOper::execCmdEx(int nCmd, int nAddr, int nVal)
{
	//遥控模式命令 就是ECCmdType枚举 
	int nCmdEx = nCmd;
	//任务模式命令 601对应1 602对应2 603对应3  604对应4
	if (nCmd >= enCExecTask)
	{
		nCmdEx = nCmd - 600;
	}
	//1.复位执行结果
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRTaskCmdExecStatus].m_sAddrData.toInt(), 0) == false)
	{
		return enResetResultFail;
	}
	//2.设置命令
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWTaskCmd].m_sAddrData.toInt(), nCmdEx) == false)
	{
		return enSetCmdFail;
	}
	else
	{
		//4.读取控制命令执行状态点值 判断PLC是否已读命令
		int nReVal = 0;
		if (m_pModBusOper->ReadVal(m_pDevDataRob->m_mapAddrDataR[enRTaskCmdExecRe].m_sAddrData.toInt(), nReVal) == false)
		{
			return enReadFail;
		}
		else
		{
			if (nReVal == nCmdEx)
			{
				m_nCtrCmdCurr = nCmd;
				return enSuccess;
			}
			else
			{
				return enPlcNoFeedBack;
			}
		}
	}
}


/********************************************************************************
*Description:复位控制命令等执行数据
*FunParameter:复位类型 0 复位控制命令，控制命令反馈，控制命令执行结果  1复位控制命令反馈，控制命令执行结果
*FunReturnValue:返回复位执行结果信息枚举
*Author:Gaojia
*Date:2024/02/02
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
int CRobCtrOper::resetExecData(int nType)
{
	m_nCtrCmdCurr = 0;
	if (nType == 0)
	{
		//1.复位控制命令
		if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWCtrCmd].m_sAddrData.toInt(), 0) == false)
		{
			return enResetCtrCmdFail;
		}
	}
	//2.复位命令执行结果
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRCtrCmdExecStatus].m_sAddrData.toInt(), 0) == false)
	{
		return enResetResultFail;
	}
	//3.复位控制命令反馈
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRCtrCmdExecRe].m_sAddrData.toInt(), 0) == false)
	{
		return enResetCtrCmdReFail;
	}
	return enSuccess;
}

int CRobCtrOper::resetTaskExecData()
{
	m_nCtrCmdCurr = 0;

	//1.复位控制命令
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWTaskCmd].m_sAddrData.toInt(), 0) == false)
	{
		return enResetCtrCmdFail;
	}

	//2.复位命令执行结果
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRTaskCmdExecStatus].m_sAddrData.toInt(), 0) == false)
	{
		return enResetResultFail;
	}
	//3.复位控制命令反馈
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataR[enRTaskCmdExecRe].m_sAddrData.toInt(), 0) == false)
	{
		return enResetCtrCmdReFail;
	}
	return enSuccess;
}

/********************************************************************************
*Description:获取控制命令执行返回值
*FunParameter:控制命令
*FunReturnValue:控制命令执行结果反馈
*Author:Gaojia
*Date:2024/02/02
*ChangeDate:
*Modifier:
*ModifyReason:
*Version:V1.0.0
********************************************************************************/
int CRobCtrOper::getCtrCmdExecResult(int nCmd)
{
	//1.获取控制命令执行标志位值 判断现在是不是还在执行该命令 如果控制命令执行标志位不是 nCmdVal 返回 命令被打断
	int nReVal = 0;
	if (m_pModBusOper->ReadVal(m_pDevDataRob->m_mapAddrDataR[enRCtrCmdExecRe].m_sAddrData.toInt(), nReVal) == false)
	{
		return enReadFail;
	}
	if (nCmd != nReVal)
	{
		return enInterruptCmd;
	}
	//2.获取控制命令执行状态  判断命令是否执行成功
	nReVal = 0;
	if (m_pModBusOper->ReadVal(m_pDevDataRob->m_mapAddrDataR[enRCtrCmdExecStatus].m_sAddrData.toInt(), nReVal) == false)
	{
		return enReadFail;
	}
	if (nReVal != 0)
	{
		if (nReVal == 1)
		{
			return enSuccess;
		}
		else
		{
			return enCtrCmeExecFail;
		}
	}
	else
	{
		return enCtrCmeExecOn;
	}
}

int CRobCtrOper::getTaskExecResult(int nCmd)
{
	//1.获取控制命令执行标志位值 判断现在是不是还在执行该命令 如果控制命令执行标志位不是 nCmdVal 返回 命令被打断
	int nReVal = 0;
	if (m_pModBusOper->ReadVal(m_pDevDataRob->m_mapAddrDataR[enRTaskCmdExecRe].m_sAddrData.toInt(), nReVal) == false)
	{
		return enReadFail;
	}
	if (nCmd != nReVal)
	{
		return enInterruptCmd;
	}
	//2.获取控制命令执行状态  判断命令是否执行成功
	nReVal = 0;
	if (m_pModBusOper->ReadVal(m_pDevDataRob->m_mapAddrDataR[enRTaskCmdExecStatus].m_sAddrData.toInt(), nReVal) == false)
	{
		return enReadFail;
	}
	if (nReVal != 0)
	{
		if (nReVal == 1)
		{
			return enSuccess;
		}
		else
		{
			return enCtrCmeExecFail;
		}
	}
	else
	{
		return enCtrCmeExecOn;
	}
}

int CRobCtrOper::waitForExecResult(int nCmd)
{
	int nTimeOut = 0;    //执行超时
	int nTimeErr = 0;    //读取错误次数
	int nReData = -1;     //函数返回值
	while (m_nCtrCmdCurr == nCmd)
	{
		int nData = getCtrCmdExecResult(nCmd);
		//1.如果命令在执行中 1000次返回
		if (nData == enCtrCmeExecOn)//等500s
		{
			nTimeOut++;
			if (nTimeOut > 1000)
			{
				nReData = enExecTimeout;
				break;
			}
			QEventLoop loop;
			QTimer::singleShot(def_refreshTime, &loop, SLOT(quit()));
			loop.exec();
		}
		//2.如果读写测定异常
		else if (nData == enReadFail)
		{
			nTimeErr++;
			if (nTimeErr > 5)
			{
				nReData = enReadFail;
				break;
			}
			QEventLoop loop;
			QTimer::singleShot(def_refreshTime, &loop, SLOT(quit()));
			loop.exec();
		}
		//3.返回执行结果
		else
		{
			nReData = nData;
			break;
		}
	}
	//如果命令被打断
	if (m_nCtrCmdCurr != nCmd)
	{
		nReData = enInterruptCmd;
	}
	return nReData;
}

int CRobCtrOper::waitForTaskExecResult(int nCmd)
{
	int nTimeOut = 0;    //执行超时
	int nTimeErr = 0;    //读取错误次数
	int nReData = -1;     //函数返回值
	while (m_nCtrCmdCurr == nCmd)
	{
		int nData = getTaskExecResult(nCmd - 600);       //任务模式命令需要偏移600
		//1.如果命令在执行中 1000次返回
		if (nData == enCtrCmeExecOn)
		{
			nTimeOut++;
			if (nTimeOut > 1000)
			{
				nReData = enExecTimeout;
				break;
			}
			QEventLoop loop;
			QTimer::singleShot(def_refreshTime, &loop, SLOT(quit()));
			loop.exec();
		}
		//2.如果读写测定异常
		else if (nData == enReadFail)
		{
			nTimeErr++;
			if (nTimeErr > 5)
			{
				nReData = enReadFail;
				break;
			}
			QEventLoop loop;
			QTimer::singleShot(def_refreshTime, &loop, SLOT(quit()));
			loop.exec();
		}
		//3.返回执行结果
		else
		{
			nReData = nData;
			break;
		}
	}
	//如果命令被打断
	if (m_nCtrCmdCurr != nCmd)
	{
		nReData = enInterruptCmd;
	}
	return nReData;
}

int CRobCtrOper::writeData(QVector<int> vecArray)
{
	//1.设置速度
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWMoveSpeed].m_sAddrData.toInt(), vecArray[0]) == false)
	{
		return enWriteParamFail;
	}
	//2.判断是否要更新plc任务数据//
	if (1)
	{
		QVector<int>nVecTagKey, vecSendArray;
		for (int k = 2; k < vecArray.size(); k++)
		{
			vecSendArray.push_back(vecArray[k]);
		}
		if (m_pModBusOper->WriteValEx(m_pDevDataRob->m_mapAddrDataW[enWPolItemCount].m_sAddrData.toInt(), vecSendArray.size(), vecSendArray) == false)
		{
			return enWriteParamFail;
		}
		if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWPolItemDataUpdate].m_sAddrData.toInt(), 1) == false)
		{
			return enWriteParamFail;
		}
	}
	else
	{
		if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWPolItemDataUpdate].m_sAddrData.toInt(), 0) == false)
		{
			return enWriteParamFail;
		}
	}
	return enSuccess;

}

int CRobCtrOper::writeData(QVector<int> vecArray, QVector<int> vecIndex)
{
	//1.设置速度
	if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWMoveSpeed].m_sAddrData.toInt(), vecArray[0]) == false)
	{
		return enWriteParamFail;
	}
	//2.判断是否要更新plc任务数据//
	if (1)
	{
		QVector<int>nVecTagKey, vecSendArray, vecIndexSend;
		for (int k = 2; k < vecArray.size(); k++)
		{
			vecSendArray.push_back(vecArray[k]);
		}
		int nLength = m_pDevDataRob->m_mapAddrDataW[enWConTaskIndex].m_nAddrLength;
		vecIndexSend = vecIndex;
		if (vecIndex.size() < nLength)
		{
			for (int i = vecIndex.size(); i < nLength; i++)
			{
				vecIndexSend.push_back(-1);
			}
		}

		if (m_pModBusOper->WriteValEx(m_pDevDataRob->m_mapAddrDataW[enWConTaskIndex].m_sAddrData.toInt(), m_pDevDataRob->m_mapAddrDataW[enWConTaskIndex].m_nAddrLength, vecIndexSend) == false)
		{
			return enWriteParamFail;
		}
		if (m_pModBusOper->WriteValEx(m_pDevDataRob->m_mapAddrDataW[enWPolItemCount].m_sAddrData.toInt(), vecSendArray.size(), vecSendArray) == false)
		{
			return enWriteParamFail;
		}
		if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWPolItemDataUpdate].m_sAddrData.toInt(), 1) == false)
		{
			return enWriteParamFail;
		}
	}
	else
	{
		if (m_pModBusOper->WriteVal(m_pDevDataRob->m_mapAddrDataW[enWPolItemDataUpdate].m_sAddrData.toInt(), 0) == false)
		{
			return enWriteParamFail;
		}
	}
	return enSuccess;
}

QString CRobCtrOper::GetDevStateStr(UINT64 nData)
{
	return QString();
}

QString CRobCtrOper::GetDevAlarmStr(UINT64 nData)
{
	if (0 != nData)
	{
		QVector<bool> vecStatus;
		QString sReStr = "";
		for (int i = 0; i < 48; i++)
		{
			bool bData = ((nData >> i) & 1);//if(status & (1 << i)
			vecStatus.push_back(bData);
		}
		if (vecStatus[40])//wxy++
		{
			sReStr += A2T("电机报警|");
		}
		if (vecStatus[41])//wxy++
		{
			sReStr += A2T("升降电机报警|");
		}
		if (vecStatus[42])
		{
			sReStr += A2T("电池电压异常|");
		}
		if (vecStatus[43])
		{
			sReStr += A2T("电池温度异常|");
		}
		if (vecStatus[44])
		{
			sReStr += A2T("电池过流报警|");
		}
		if (vecStatus[45])
		{
			sReStr += A2T("电池模块故障|");
		}
		if (vecStatus[46])
		{
			sReStr += A2T("电池短路保护故障|");
		}
		if (vecStatus[47])
		{
			sReStr += A2T("低压禁止充放电故障|");
		}
		if (vecStatus[33])
		{
			sReStr += A2T("设备刚上电未校零|");
		}
		if (vecStatus[34])
		{
			sReStr += A2T("前雷达避障报警|");//add
		}
		if (vecStatus[35])
		{
			sReStr += A2T("后雷达避障报警|");//add
		}
		if (vecStatus[38])
		{
			sReStr += A2T("急停被按下故障|");
		}
		if (vecStatus[24])
		{
			sReStr += A2T("到达前进限位|");
		}
		if (vecStatus[25])
		{
			sReStr += A2T("到达后退限位|");
		}
		if (vecStatus[26])
		{
			sReStr += A2T("RFID通讯故障|");
		}
		if (vecStatus[27])
		{
			sReStr += A2T("电机通讯故障|");
		}
		if (vecStatus[28])
		{
			sReStr += A2T("充电器通讯故障|");
		}
		if (vecStatus[29])
		{
			sReStr += A2T("电池通讯故障|");
		}
		if (vecStatus[30])
		{
			sReStr += A2T("非充电位长时间停留|");//add
		}
		if (vecStatus[31])
		{
			sReStr += A2T("循环充电失败|");//add
		}
		if (vecStatus[16])
		{
			sReStr += A2T("行走电机电流过大故障|");
		}
		if (vecStatus[17])
		{
			sReStr += A2T("行走电机力矩过大故障|");
		}
		if (vecStatus[20])
		{
			sReStr += A2T("驱动电机温度过高故障|");//add
		}
		if (vecStatus[21])
		{
			sReStr += A2T("升降电机温度过高故障|");//add
		}
		if (vecStatus[22])
		{
			sReStr += A2T("云台避障报警|");//add
		}
		if (vecStatus[8])
		{
			sReStr += A2T("单体过压保护|");
		}
		if (vecStatus[9])
		{
			sReStr += A2T("单体欠压保护|");
		}
		if (vecStatus[10])
		{
			sReStr += A2T("整组过压保护|");
		}
		if (vecStatus[11])
		{
			sReStr += A2T("整组欠压保护|");
		}
		if (vecStatus[12])
		{
			sReStr += A2T("充电过温保护|");

		}
		if (vecStatus[13])
		{
			sReStr += A2T("充电低温保护|");
		}
		if (vecStatus[14])
		{
			sReStr += A2T("放电过温保护|");
		}
		if (vecStatus[15])
		{
			sReStr += A2T("放电低温保护|");
		}
		if (vecStatus[0])
		{
			sReStr += A2T("充电过流保护|");
		}
		if (vecStatus[1])
		{
			sReStr += A2T("放电过流保护|");
		}
		if (vecStatus[2])
		{
			sReStr += A2T("短路保护|");
		}
		if (vecStatus[5])
		{
			sReStr += A2T("充电使能|");
		}
		if (vecStatus[7])
		{
			sReStr += A2T("电池低电量故障|");
		}
		if (sReStr == "")
		{
			return A2T("其他故障");
		}
		else
		{
			return sReStr;
		}
	}
	else
	{
		return A2T("正常");
	}
}

void CRobCtrOper::saveCsvData(QString sPath, QString sFileName, QString sOutStr, QString sTitle)
{
	bool bIsHaveTitle = false;
	bIsHaveTitle = IsHaveData(sPath, sFileName);
	QDir m_tDir = QDir::current();
	if (!m_tDir.exists(sPath))
	{
		m_tDir.mkpath(sPath);
	}
	QString sUrl = sPath + "/" + sFileName;
	QFile m_tFile(m_tDir.filePath(sUrl));
	m_tFile.open(QIODevice::Append | QIODevice::ReadWrite);
	QTextStream out(&m_tFile);
	QString sStr = out.readLine();
	//如果是空表格就加入表头
	if (!bIsHaveTitle)
	{
		out << sTitle;
	}
	out << sOutStr;
	m_tFile.flush();
	m_tFile.close();
}



bool CRobCtrOper::IsHaveData(QString sPath, QString sFileNane)
{
	QDir m_tDir = QDir::current();
	if (!m_tDir.exists(sPath))
	{
		return false;
	}
	QString sUrl = sPath + "/" + sFileNane;
	QFile m_tFile(m_tDir.filePath(sUrl));
	m_tFile.open(QIODevice::ReadOnly);
	QTextStream out(&m_tFile);
	QString sStr = out.readLine();
	//如果是空表格就加入表头
	if (sStr.size() < 100)
	{
		return false;
	}
	else
	{
		return true;
	}
}

